<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		请输入数字: <input type="text" onkeypress="check()">
		<script type="text/javascript">
			function check(){
				if(event.keyCode<48 || event.keyCode > 57){
					alert("不能输入非数字");
					event.preventDefault();
					return false;
				}
			}
		</script>
	</body>
</html>
